#include <iostream>

#include <memory>
#include "UDP_Server.hpp"
#include "MessageRoute.hpp"

//./udpserver ip port
//using func = std::function<void(int sockfd, const std::string message, const InetAddr addr)>;
void usage(std::string proc){
    std::cout << "Usage: \n\t" << proc <<  " local_ip  local_port\n" << std::endl;
}

int main(int argc, char* argv[]){
    if(argc != 2){
        usage(argv[0]);
        exit(USAGE_ERROR);
    }
    EnableFile();
    uint16_t port = std::stoi(argv[1]);
    //网络
    MessageRoute route;

    std::unique_ptr<UdpServer> user = std::make_unique<UdpServer>(port, 
        std::bind(&MessageRoute::Route, &route, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
    
    user->InitServer();
    user->Start();
    return 0;
}

